// -----------------------------------------------------------------------
//  <copyright file="ValidUserRoleForUserSpec.cs" company="LiuliuSoft">
//      Copyright (c) 2022-2025 DaprPlus. All rights reserved.
//  </copyright>
//  <site>https://dapr.plus</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2025-01-09 15:00</last-date>
// -----------------------------------------------------------------------

using DaprPlus.Domain.Entity;

namespace DaprPlus.Identity.Domain.Specs;

/// <summary>
/// 查询用户的有效角色（未过期的）
/// </summary>
/// <typeparam name="TUserRole">用户角色类型</typeparam>
/// <param name="userId">用户ID</param>
public class ValidUserRoleForUserSpec<TUserRole>(long userId) : SpecificationBase<TUserRole>(m =>
    m.UserId == userId &&
    (m.BeginTime == null || m.BeginTime.Value <= DateTime.Now) &&
    (m.EndTime == null || m.EndTime.Value >= DateTime.Now))
    where TUserRole : UserRoleBase
{ }
